package com.example.springdemo.design_model.contrete;

import lombok.Getter;

/**
 * 简要建造者模式
 * 适用于多个参数，并且有的参数必填，有的非必填
 * 可以链式调用
 * @author zhangding
 * @date
 */
public class SimpleBuilderModel {
    @Getter
    private String mustOne;
    @Getter
    private String mustTwo;
    @Getter
    private String changeOne;
    @Getter
    private String changeTwo;
    SimpleBuilderModel(Builder builder){
        this.mustOne = builder.mustOne;
        this.mustTwo = builder.mustTwo;
        this.changeOne = builder.changeOne;
        this.changeTwo = builder.changeTwo;
    }
    public static class Builder{
        private String mustOne;
        private String mustTwo;
        private String changeOne;
        private String changeTwo;

        public Builder setChangeOne(String changeOne) {
            this.changeOne = changeOne;
            return this;
        }

        public Builder setChangeTwo(String changeTwo) {
            this.changeTwo = changeTwo;
            return this;
        }

        public Builder(String mustOne, String mustTwo){
            this.mustOne = mustOne;
            this.mustTwo = mustTwo;
        }
        public SimpleBuilderModel build(){
            return new SimpleBuilderModel(this);
        }
    }

}
class Test{
    public static void main(String[] args) {
        SimpleBuilderModel simpleBuilderModel = new  SimpleBuilderModel.Builder("77","888")
                                                                        .setChangeOne("sss")
                                                                        .setChangeTwo("999")
                                                                        .build();
        System.out.println(simpleBuilderModel.getChangeOne());
    }
}
